<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="order by dede58.com"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>笔记库后台-用户管理</title>
    <#include "public/link_css.ftl">
    <#include "public/link_js.ftl">
    <#--    <script>window.location.href='upgrade-browser.html';</script>-->
</head>

<body class="user-select">
<section class="container-fluid">
    <#include "public/header.ftl">
    <div class="row">
        <#include "public/left.ftl">
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
            <h1 class="page-header">操作</h1>
            <ol class="breadcrumb">
                <li><a data-toggle="modal" data-target="#addUser">增加用户</a></li>
            </ol>
            <h1 class="page-header">管理 <span class="badge">2</span></h1>
            <div class="table-responsive">
                <table class="table table-striped table-hover">
                    <thead>
                    <tr>
                        <th><span class="glyphicon glyphicon-th-large"></span> <span class="visible-lg">ID</span></th>
                        <th><span class="glyphicon glyphicon-user"></span> <span class="visible-lg">用户名</span></th>
                        <th><span class="glyphicon glyphicon-bookmark"></span> <span class="visible-lg">昵称</span></th>
                        <th><span class="glyphicon glyphicon-pushpin"></span> <span class="visible-lg">文章总数</span></th>
                        <th><span class="glyphicon glyphicon-pushpin"></span> <span class="visible-lg">邮箱地址</span></th>
                        <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">上次登录时间</span></th>
                        <th><span class="glyphicon glyphicon-pencil"></span> <span class="visible-lg">操作</span></th>
                    </tr>
                    </thead>
                    <tbody>
                    <#if userManagerList??>
                        <#list userManagerList as user>
                            <tr>
                                <td>${user.id}</td>
                                <td>${user.username}</td>
                                <td>${user.nickname}</td>
                                <td>${user.noteCount}</td>
                                <td>${user.email}</td>
                                <td>${user.lastLoginTime}</td>
                                <td><a href="/admin/user/update?id=${user.id}">修改</a>
                                    <a href="/admin/user/delete?id=${user.id}">删除</a>
                                    <a data-toggle="modal"
                                       data-target="#roleModal" data-whatever="${user.id}">分配角色</a>
                                </td>
                            </tr>
                        </#list>
                    </#if>


                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>
<!--增加用户模态框-->
<div class="modal fade" id="addUser" tabindex="-1" role="dialog" aria-labelledby="addUserModalLabel">
    <div class="modal-dialog" role="document" style="max-width:450px;">
        <form action="/admin/user/userAdd" method="post" autocomplete="off" draggable="false">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">添加用户</h4>
                </div>
                <div class="modal-body">
                    <table class="table" style="margin-bottom:0px;">
                        <thead>
                        <tr></tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td wdith="20%">账户名:</td>
                            <td width="80%"><input type="text" value="" class="form-control" name="username"
                                                   maxlength="10" autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">昵称:</td>
                            <td width="80%"><input type="text" value="" class="form-control" name="nickname"
                                                   maxlength="10" autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">密码:</td>
                            <td width="80%"><input type="password" class="form-control" name="password" maxlength="18"
                                                   autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">邮箱:</td>
                            <td width="80%">
                                <input type="email" class="form-control" name="email" maxlength="40"
                                       autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">电话:</td>
                            <td width="80%"><input type="text" class="form-control" name="phone" maxlength="13"
                                                   autocomplete="off"/></td>
                        </tr>
                        <tr>
                            <td wdith="20%">性别:</td>
                            <td width="80%">
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="男"> 男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="女"> 女
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex" value="保密"> 保密
                                </label>
                            </td>
                        </tr>
                        </tbody>
                        <tfoot>
                        <tr></tr>
                        </tfoot>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="roleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form method="post" action="/admin/user/addRole">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">角色列表</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="uid">
                    <#if roleList??>
                        <#list roleList as role>
                            <label class="checkbox-inline">
                                <input type="checkbox" name="roleIds" value="${role.id}"> ${role.role}
                            </label>
                        </#list>
                    </#if>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">添加/修改权限</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('#roleModal').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget) // 获取触发的控件
        var recipient = button.data('whatever') // 获取携带的值
        var modal = $(this)
        modal.find('.modal-body input[type=hidden]').val(recipient) // 为input type=hidden赋值
    })
</script>
</body>
</html>
